Java Variable
- A variable is a container which holds the value while the Java program is executed. A variable is assigned with a data type.
- JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform dependent because the configuration of each OS is different from each other. However, Java is platform independent. There are three notions of the JVM: specification, implementation, and instance.
- Variable is a name of memory location. There are three types of variables in java: local, instance and static.
-
There are two types of data types in Java
- primitive
- non-primitive.
Variable
A variable is the name of a reserved area allocated in memory. In other words, it is a name of the memory location. It is a combination of "vary + able" which means its value can be changed.
int data=50; //Here data is variable
Types of Variables
- local variable
- instance variable
- static variable
- Local Variable
- Instance Variable
- Static variable
Example to understand the types of variables in java
public class A
{
static int m=100;//static variable
void method()
{
int n=90;//local variable
}
public static void main(String args[])
{
int data=50;//instance variable
}
}